package com.jyw.web.controller.system;

import com.jyw.common.annotation.Log;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.system.domain.dto.SysKnowledgeReviewConfigAddDto;
import com.jyw.system.domain.dto.SysKnowledgeReviewConfigEditDto;
import com.jyw.system.domain.dto.SysKnowledgeReviewConfigQueryDto;
import com.jyw.system.domain.vo.SysKnowledgeReviewConfigVo;
import com.jyw.system.domain.vo.SysKnowledgeReviewDetailVo;
import com.jyw.system.service.ISysKnowledgeReviewConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author Created by ZhangCheng on 2023/08/17 (系统知识审核配置)
 */
@Api(tags = "系统知识审核配置")
@RestController
@RequestMapping("/system/knowledgeReviewConfig")
public class SysKnowledgeReviewConfigController {

    @Resource
    private ISysKnowledgeReviewConfigService sysKnowledgeReviewConfigService;

    /**
     * 获取知识审核启用配置
     *
     * @return
     */
    @GetMapping("/getConfig")
    @ApiOperation("获取知识审核启用配置")
    public CommonResult<SysKnowledgeReviewDetailVo> getConfig() {
        return CommonResult.success(sysKnowledgeReviewConfigService.getDefaultConfig());
    }

    /**
     * 修改知识审核启用配置
     *
     * @param sysKnowledgeReviewConfigVo
     * @return
     */
    @Log(title = "修改知识审核启用配置", businessType = BusinessType.UPDATE)
    @PutMapping("/updateConfig")
    @ApiOperation("修改知识审核启用配置")
    public CommonResult updateConfig(@RequestBody @Valid SysKnowledgeReviewDetailVo sysKnowledgeReviewConfigVo) {
        sysKnowledgeReviewConfigService.updateConfig(sysKnowledgeReviewConfigVo);
        return CommonResult.success();
    }

    /**
     * 查询知识审核故障分类配置
     *
     * @return
     */
    @GetMapping("/getFaultTypeList")
    @ApiOperation("查询知识审核故障分类配置")
    public CommonResult<SysKnowledgeReviewConfigVo> getFaultTypeList(SysKnowledgeReviewConfigQueryDto queryDto) {
        List<SysKnowledgeReviewConfigVo> list = sysKnowledgeReviewConfigService.queryFaultTypeList(queryDto);
        return CommonResult.success(list);
    }

    /**
     * 新增知识审核故障分类配置
     */
    @Log(title = "知识审核故障分类配置", businessType = BusinessType.INSERT)
    @PostMapping(value = "add")
    @ApiOperation("新增知识审核故障分类配置")
    public CommonResult add(@RequestBody @Valid SysKnowledgeReviewConfigAddDto addDto) {
        sysKnowledgeReviewConfigService.add(addDto);
        return CommonResult.success();
    }

    /**
     * 修改知识审核故障分类配置
     */
    @Log(title = "知识审核故障分类配置", businessType = BusinessType.UPDATE)
    @PutMapping(value = "edit")
    @ApiOperation("修改知识审核故障分类配置")
    public CommonResult edit(@RequestBody @Valid SysKnowledgeReviewConfigEditDto editDto) {
        sysKnowledgeReviewConfigService.edit(editDto);
        return CommonResult.success();
    }
}
